package org.myOrg.spetrum.io;

import org.myOrg.spetrum.testObject.TestCase;
import org.myOrg.spetrum.testObject.TestSuite;

/**
 * 
 * @author Xintao Niu
 * 
 */
public class InputManagerImplement implements InputManager {

	private ValidateFormat validator;
	private ReadSuite reader;
	private String formatInfo;
	private boolean formatPass;

	public InputManagerImplement() {

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.myOrg.spetrum.inputFormat.InputManager#getParam()
	 */
	@Override
	public int[] getParam() {
		if (reader != null)
			return reader.getParam();
		else
			return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.myOrg.spetrum.inputFormat.InputManager#getTestSuite()
	 */
	@Override
	public TestSuite getTestSuite() {
		if (reader != null)
			return reader.getTestSuit();
		else
			return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.myOrg.spetrum.inputFormat.InputManager#getFailInfo()
	 */
	@Override
	public String getFormatlInfo() {
		return formatInfo;
	}

	@Override
	public void deal(String path) {
		// TODO Auto-generated method stub
		validator = new ValidateImplement();
		if (formatPass = validator.validate(path)) {
			reader = new ReaderImplement();
			reader.read(validator);
		}
		formatInfo = validator.getJudgeDescription();
	}

	@Override
	public TestSuite getRightSuite() {
		// TODO Auto-generated method stub
		return this.reader.getTestSuit().getInfoTestCases(TestCase.PASSED);
	}

	@Override
	public TestSuite getWrongSuite() {
		// TODO Auto-generated method stub
		return this.reader.getTestSuit().getInfoTestCases(TestCase.FAILED);
	}

	@Override
	public boolean isFormatPass() {
		// TODO Auto-generated method stub
		return formatPass;
	}
}
